// 定义全局指令，这个directives也可以抽离成单文件
const directives = {
  color: {
    mounted (el, binding) {
      el.style.color = binding.value
    }
  },
  debounce: {
    mounted (el, binding) {
      let timer
      el.addEventListener('click', () => {
        if (timer) {
          clearTimeout(timer)
        }
        timer = setTimeout(() => {
          binding.value()
        }, 300)
      })
    }
  }

}
export default {
  install (app) {
    Object.keys(directives).forEach((key) => {
      app.directive(key, directives[key])
    })
  }
}
